import { addListener } from '../utils/gestures.js'

const events = ['down', 'up', 'tap', 'track']

export default {
  install(Vue) {
    events.forEach((eventName) => {
      Vue.directive(eventName, {
        bind(target, binding) {
          addListener(target, eventName, (event) => {
            if(binding.modifiers.stop) {
              event.stopPropagation();
            }
            if(binding.modifiers.prevent) {
              event.preventDefault();
            }
            if(binding && binding.value) {
              binding.value(event);
            }
          })
        }
      })
    })
  }
}